package dhm.com.dhmshop.adapter.home;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;

import java.util.ArrayList;
import java.util.List;

import dhm.com.dhmshop.R;
import dhm.com.dhmshop.base.netWork.Constant;
import dhm.com.dhmshop.entity.GoodsConsult;

/**
 * Created by admin
 * 2019/4/29
 * 所有订单适配器
 */
public class GoodsConsultAdapter extends RecyclerView.Adapter<GoodsConsultAdapter.ViewHolder> {

    private List<GoodsConsult.DataBean> list;
    private Context context;


    public GoodsConsultAdapter(List<GoodsConsult.DataBean> list, Context context) {
        this.list=new ArrayList<>();
        this.context = context;
    }

    public void setList(List<GoodsConsult.DataBean> list) {
        this.list = list;
        notifyDataSetChanged();
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        ViewHolder viewHolder;
        View view= LayoutInflater.from(context).inflate(R.layout.item_goodsconsult, null);
        viewHolder=new ViewHolder(view);
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder viewHolder, final int i) {
        if (list.get(i).getLoginName()==null||list.get(i).getLoginName().equals("")){
            viewHolder.nickname.setText("游客");
        }else {
            viewHolder.nickname.setText(list.get(i).getLoginName());
        }
        viewHolder.time.setText(list.get(i).getCreateTime());
        viewHolder.consultContent.setText(list.get(i).getConsultContent());
        viewHolder.reply.setText(list.get(i).getReply());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        public TextView nickname;
        public TextView time;
        public TextView consultContent;
        public TextView reply;

        public ViewHolder(@NonNull View itemView) {
            super(itemView);
            nickname=itemView.findViewById(R.id.nickname);
            time=itemView.findViewById(R.id.time);
            consultContent=itemView.findViewById(R.id.consultContent);
            reply=itemView.findViewById(R.id.reply);
        }
    }

    private OnClick onClick;
    public void setdeleteClick(OnClick onClick) {
        this.onClick = onClick;
    }
    public interface OnClick{
        void item(int posttion);
    }

    private OnIntentClick onIntentClick;
    public void setaddClick(OnIntentClick onClick) {
        this.onIntentClick = onClick;
    }
    public interface OnIntentClick{
        void item();
    }



}

